Published on

My little WPF music player

Reading time
2 分钟
Page view
-
Author
  • avatar
    Name
    Yicong
    Github

🎵 MusicPlayer

A powerful, modern C# WPF local music player built with Fluent Design, supporting multiple audio formats, lyrics display, audio visualization, and more.

✨ Key Features

🎧 Audio Playback

  • Multi-Format Support: MP3, WAV, FLAC, M4A, OGG/OGA, AAC, WMA, and other mainstream audio formats
  • Full Playback Control: Play/Pause/Stop, Previous/Next, Seek
  • Volume Control: Adjustable volume slider and mute functionality
  • Audio Info Display: Shows song title, artist, album information, and cover art

🎤 Lyrics Features

  • Multi-Format Lyrics: Supports embedded lyrics and external .srt, .lrc files
  • Bilingual Lyrics: Automatically detects and displays both Chinese and English lyrics simultaneously
  • Auto-Sync: Lyrics scroll automatically with playback progress, highlighting the current line
  • Smart Loading: Automatically loads lyric files with the same name as the music file

📚 Playlist Management

  • Local Music Import: Supports single file or batch import of music files
  • Search & Filter: Quick search and filtering within the playlist
  • Collapsible Design: Foldable/expandable playlist to save interface space
  • Data Persistence: Uses JSON files for local storage of playlist information
  • Portable Design: All data files reside in the same directory as the executable for easy portability

🎨 Modern UI

  • Fluent Design: Implements Microsoft's Fluent Design System
  • Acrylic Blur Effect: Mica background material with modern semi-transparent visuals
  • Custom Window: Custom title bar design that matches the application's style
  • Circular Artwork: Album covers displayed in a circular format with rotating animation during playback
  • Dynamic Background: Gaussian blurred album art background for an immersive visual experience

🎵 Audio Visualization

  • Real-time Spectrum: FFT-based audio spectrum analyzer
  • Dynamic Effects: Pulsating bar graphs synchronized with music rhythm
  • Visual Feedback: Rich visual effects to enhance the music experience

🖼️ Dynamic Background System

  • Smart Background: Automatically uses the current song's album art as a blurred background
  • Gaussian Blur: 40-pixel radius blur effect ensuring foreground content remains clear and readable
  • Smooth Transitions: 0.8-second smooth animation when switching songs
  • Default Gradient: Elegant blue gradient background when no album art is available
  • Layered Rendering: Gradient overlay ensures optimal contrast and readability for interface elements

🏗️ Technical Architecture

Core Technology Stack

  • Development Framework: C# + WPF (.NET 8.0)
  • UI Framework: WPF-UI 4.0.3 - Modern WPF UI component library
  • Audio Processing: NAudio 2.2.1 + NAudio.Vorbis 1.5.0
  • Metadata Handling: TagLib-Sharp 2.3.0
  • Data Serialization: System.Text.Json

Architecture Patterns

  • Design Pattern: MVVM (Model-View-ViewModel)
  • Data Binding: WPF data binding and command patterns
  • Audio Engine: NAudio WaveOut + Custom spectrum analyzer
  • File System: Local JSON storage, portable green design

📦 Project Structure

MusicPlayer/
├── App.xaml/cs                    
├── MainWindow.xaml/cs             
├── MusicPlayer.csproj              
├── Audio/                         
│   ├── SpectrumAnalyzer.cs        
│   └── VorbisAudioFileReader.cs   
├── Converters/                    
│   ├── SpectrumHeightConverter.cs 
│   ├── PlaylistWidthConverter.cs  
│   ├── BlurEffectConverter.cs     
│   └── NotNullToBooleanConverter.cs 
├── Models/                         
│   ├── Song.cs                    
│   └── LyricLine.cs               
├── Services/                       
│   └── PlaylistService.cs         
├── ViewModels/                     
│   ├── MainViewModel.cs           
│   └── ObservableObject.cs      
└── docx/                          
    └── README.md                 

How it looks

music